package com.lh.bootswagger.controller;

import com.lh.bootswagger.entity.ApiPermission;
import com.lh.bootswagger.service.JpaTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lh
 * @Description: jpa相关查询联系
 * @date 2021/5/11 10:13
 */
@RestController
@RequestMapping("/jpa")
public class JpaController {

	@Autowired
	private JpaTestService jpaTestService;

	/**
	 * 左连复杂查询联系
	 *
	 * @param appId
	 * @param reqUrl
	 * @return
	 */
	@GetMapping("/findApiPermission")
	@ResponseBody
	public List<ApiPermission> findApiPermission(String appId, String reqUrl) {
		List<ApiPermission> apiPermission = jpaTestService.findApiPermission(appId, reqUrl);
		if (!CollectionUtils.isEmpty(apiPermission)) {
			ApiPermission apiPermission1 = apiPermission.get(0);
			System.out.println(apiPermission1);
		}
		return apiPermission;
	}
}
